<template>
  <section class="chatYe">
    <MyHeader />
    <!-- 轮播。需要获取数据 -->
    <van-swipe :autoplay="3000" lazy-render>
      <van-swipe-item v-for="image in images" :key="image">
        <img :src="image" />
      </van-swipe-item>
    </van-swipe>
    <section class="doubleLi">
      <div class="shuxian">搜索</div>
      <div>分类</div>
    </section>
    <section class="main-Banner">
      <section
        class="topic-Banner"
        v-for="(item, index) in book.title"
        :key="index"
      >
        <div class="hot-Topic">{{ item[2] }}</div>
        <div class="more-Text">更多</div>
        <div class="more-array">></div>
        <ul class="topic-rander">
          <li>
            <div class="topic-Title" v-for="item in book.title" :key="item">
              <p>
                <span>#</span>{{ item[0][index] }}
                <span class="titleTwo">{{ item[1][index] }}条讨论</span>
              </p>
            </div>
            <div class="topic-T"></div>
          </li>
        </ul>
      </section>
    </section>
    <main>
      <p>今天聊什么</p>
      <van-tabs
        v-model:active="active"
        title-active-color="#72CDCD"
        title-inactive-color="#8F8F8F"
      >
        <van-tab title="关注">我是关注里面的内容</van-tab>
        <van-tab title="精选">
          <!-- <div class="wrap"> -->
          <section class="content-Point" v-for="item in dataList" :key="item">
            <div class="left-Div">
              <div class="gray-div">
                <span>{{ item.title }}</span>
              </div>
              <div class="myPic">
                <img :src="item.imgUrl" alt="" />
              </div>
              <p>{{ item.toPic }}</p>
              <section class="content-Bot">
                <div class="bot-Img">
                  <img :src="item.imgPop" alt="" /><span>{{
                    item.popName
                  }}</span>
                </div>
                <div class="dianZan">
                  <i>👍</i><span>{{ item.good }}</span>
                </div>
              </section>
            </div>
            <div class="right-Div">
              <div class="gray-div">
                <span>我不合适</span>
              </div>
              <p style="margin-top: 10%">
                "法国cattier矿物泥面膜四五十块钱便宜大碗好用！"
              </p>
              <section class="content-Bot" style="margin-top: 10%">
                <div class="bot-Img">
                  <img
                    src="http://121.40.124.132:3000/images/chat/tu3.png"
                    alt=""
                  /><span>小熊软糖</span>
                </div>
                <div class="dianZan"><i>👍</i><span>173</span></div>
              </section>

              <div class="gray-div" style="margin-top: 8px">
                <span>我真的不合适合适</span>
              </div>
              <p style="margin-top: 10%">"你想聊的话题！"</p>
              <section class="content-Bot" style="margin-top: 10%">
                <div class="bot-Img">
                  <img
                    src="http://121.40.124.132:3000/images/chat/tu3.png"
                    alt=""
                  /><span>熊熊硬糖</span>
                </div>
                <div class="dianZan"><i>👍</i><span>5364</span></div>
              </section>
            </div>
          </section>
          <!-- </div> -->
        </van-tab>
        <van-tab title="新帖">我是新帖里面</van-tab>
        <van-tab title="一周最热">我是一周最热里面的内容</van-tab>
      </van-tabs>
    </main>

    <Footer />
  </section>
</template>

<script>
// import BetterScroll from "better-scroll";
import MyHeader from "@/components/public/MyHeader.vue";
import Footer from "@/components/Footer.vue";
import { ref, reactive } from "vue";
// import axios from "axios";
import { getchatApi } from "../../utils/api";

export default {
  components: {
    MyHeader,
    Footer,
  },
  data() {
    return {
      dataList: [],
    };
  },

  mounted() {
    this.getList();
  },

  methods: {
    async getList() {
      const res = await getchatApi();
      this.dataList = res;
      //betterscroll
      // const bs = new BetterScroll(".wrap", {
      //   scrollX: false,
      //   scrollY: true,
      //   click: true,
      //   pullUpLoad: true,
      // });
      // bs.on("pullingUp", () => {
      //   console.log("到底了");
      // });
    },
  },

  setup() {
    const active = ref(1);

    const images = [
      "http://121.40.124.132:3000/images/chat/banner.png",
      "http://121.40.124.132:3000/images/chat/banner.png",
      "http://121.40.124.132:3000/images/chat/banner.png",
      "http://121.40.124.132:3000/images/chat/banner.png",
    ];

    const readersNumber = ref(0);
    const book = reactive({
      title: [
        [
          ["「征集」你想聊的话题", "适合油皮的眼霜推荐", "适合什么什么吗推荐"],
          ["39.1k", "1111", "4564"],
          "热门话题",
        ],
        [
          ["你们是每天敷面膜吗", "大油田也别作死", "我是随便的数据"],
          ["1671", "4562", "122k"],
          "同肤质在聊",
        ],
        [
          [
            "给学生党的彩妆合集（评价又好用）",
            "白天脸上爱出油",
            "晚上也爱出游",
          ],
          ["1877", "566k", "3654"],
          "新话题",
        ],
      ],
    });

    return {
      images,
      book,
      readersNumber,
      active,
    };
  },
};
</script>

<style lang="less">
.chatYe {
  background: white;

  .van-swipe-item {
    img {
      width: 100%;
      height: 125px;
    }
  }
  .doubleLi {
    display: flex;
    height: 53px;
    border-bottom: 1px solid gray;
    justify-content: space-evenly;

    .shuxian {
      position: relative;
    }

    .shuxian::after {
      content: "";
      position: absolute;
      top: 10%;
      right: 0;
      background: #e6dfdf;
      width: 1px;
      height: 40px;
    }

    div {
      width: 45%;
      height: 100%;
      line-height: 53px;
      text-align: center;
      font-size: 15px;
    }
  }

  .main-Banner {
    width: 100%;
    height: 480px;
    margin-top: 30px;

    .topic-Banner {
      width: 95%;
      margin-left: 5%;
      height: 140px;
      position: relative;
      border-bottom: 1px solid #f1f1f1;
      overflow: hidden;
      margin-top: 30px;

      .hot-Topic {
        height: 15.5px;
        font-size: 16px;
        font-family: PingFang;
        font-weight: bold;
        color: #000000;
      }

      .more-Text {
        width: 25px;
        height: 12.5px;
        font-size: 12px;
        font-family: PingFang;
        font-weight: bold;
        color: #b9b9b9;
        position: absolute;
        top: 2px;
        right: 22px;
      }

      .more-array {
        font-size: 14px;
        width: 6.5px;
        height: 11.5px;
        position: absolute;
        top: 2px;
        right: 10px;
        color: #b9b9b9;
      }
      .topic-rander {
        margin-top: 27px;

        p {
          margin-top: 20px;
        }

        span {
          color: #78cccd;
          font-size: 14px;
        }

        .topic-Title {
          height: 14px;
          font-size: 13px;
          font-family: PingFang;
          font-weight: bold;
          color: #010101;
        }

        .titleTwo {
          font-size: 10px;
          font-family: PingFang;
          font-weight: bold;
          color: #afafaf;
          margin-left: 10px;
        }

        .topic-T {
          width: 65px;
          height: 10px;
          font-size: 10px;
          font-family: PingFang;
          font-weight: bold;
          color: #afafaf;
        }
      }
    }
  }

  main {
    margin-top: 30px;

    p {
      font-size: 16px;
      font-family: PingFang;
      font-weight: bold;
      color: #000000;
      margin-left: 5%;
    }

    .van-tabs {
      margin-top: 15px;
    }
    .van-tabs__nav {
      margin-left: 55px;
    }
    .van-tabs__line {
      width: 75px;
      background-color: #72cdcd;
    }
  }

  .wrap {
    width: 96%;
    margin: auto;
    border-radius: 5px;
    margin-top: 5px;
  }

  .content-Point {
    width: 96%;
    margin: auto;
    border-radius: 5px;
    margin-top: 5px;
    display: flex;

    .left-Div {
      height: 314px;
      width: 48.5%;
      border: 1px solid #ccc;
      border-radius: 5px;

      .myPic {
        width: 100%;
        height: 55%;
        background-color: greenyellow;

        img {
          width: 100%;
          height: 100%;
        }
      }

      p {
        margin: 10% 2%;
        font-size: 13px;
        font-weight: normal;
        height: 35px;
      }
    }

    .right-Div {
      border-bottom: 5px solid white;
      height: 160px;
      width: 48.5%;
      border: 1px solid #ccc;
      border-radius: 5px;
      margin-left: 3%;

      p {
        margin: 10% 2%;
        font-size: 13px;
        font-weight: normal;
        height: 55px;
      }
    }

    .gray-div {
      width: 100%;
      height: 35px;
      background-color: rgb(228, 228, 228);
      border-bottom: 1px solid #ccc;
      border-radius: 5px;

      span {
        display: block;
        font-size: 15px;
        text-align: center;
        width: 100%;
        line-height: 35px;
      }
    }

    .content-Bot {
      display: flex;
    }

    .bot-Img {
      margin-left: 3%;
      width: 100px;
      display: flex;
      align-items: center;

      img {
        width: 20px;
        height: 20px;
      }

      span {
        margin-left: 5%;
        font-size: 11px;
      }
    }
    .dianZan {
      color: grey;
      font-size: 12px;
      line-height: 30px;
      margin-left: 22px;
    }
  }
}
</style>
